Date.prototype.getDateStr = function () {
    var date = new Date();
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var day = date.getDate();
    var hour = date.getHours();
    var minute = date.getMinutes();
    var second = date.getSeconds();
    var str = year + '年' + month + '月' + day + '日 ' + hour + ':' + minute + ':' + second;
    return str;
};

Date.prototype.getTimeStr = function () {
    var hour = date.getHours();
    var minute = date.getMinutes();
    var second = date.getSeconds();
    var str = hour + ':' + minute + ':' + second;
    return str;
};


function log(data) {
    console.log(data)
}

// addWindowDialog();


function openSelectWindow(url, title, param, callback) {
    if (undefined !== callback) {
        window.windowCallback = callback;
    }
    if (undefined !== param) {
        window.windowParam = param;
    }
    window.open(url, "", "toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no,titlebar=no,width=400,height=400")
}
function closeSelectWindow(value) {
    if (window.opener.windowCallback !== undefined) {
        window.opener.windowCallback(value);
    }
    window.close();

}

function getWindowParam() {
    if (window.opener!=null) {
        if (undefined !== window.opener.windowParam)
        {
            return window.opener.windowParam;
        }
    }
}

function showSelectPointMap() {
    var value=this.value;
    var param=null;
    if(value)
    {
        param={
            center:value,
        };
    }
    var obj=[];
    var id=this.id;
    var callback=function (data) {
        $("#"+id).textbox("setValue",data.lng+","+data.lat);
    };
    openSelectWindow("/HtmlDemo/myDemo/open_window/selectMap.html","test",param,callback);
}

/**
 * 为浏览器添加ModalDialog方法
 */
function addWindowDialog() {
    var has_showModalDialog = !!window.showModalDialog;//定义一个全局变量判定是否有原生showModalDialog方法
    if (!has_showModalDialog && !!(window.opener)) {
        window.onbeforeunload = function () {
            window.opener.hasOpenWindow = false;        //弹窗关闭时告诉opener：它子窗口已经关闭
        }
    }
//定义window.showModalDialog如果它不存在
    if (window.showModalDialog == undefined) {
        window.showModalDialog = function (url, mixedVar, features) {
            if (window.hasOpenWindow) {
                alert("您已经打开了一个窗口！请先处理它");//避免多次点击会弹出多个窗口
                window.myNewWindow.focus();
            }
            window.hasOpenWindow = true;
            if (mixedVar) var mixedVar = mixedVar;
            //因window.showmodaldialog 与 window.open 参数不一样，所以封装的时候用正则去格式化一下参数
            if (features) var features = features.replace(/(dialog)|(px)/ig, "").replace(/;/g, ',').replace(/\:/g, "=");
            //window.open("Sample.htm",null,"height=200,width=400,status=yes,toolbar=no,menubar=no");
            //window.showModalDialog("modal.htm",obj,"dialogWidth=200px;dialogHeight=100px");
            var left = (window.screen.width - parseInt(features.match(/width[\s]*=[\s]*([\d]+)/i)[1])) / 2;
            var top = (window.screen.height - parseInt(features.match(/height[\s]*=[\s]*([\d]+)/i)[1])) / 2;
            window.myNewWindow = window.open(url, "_blank", features);
        }
    }
};
function jumpMapSelectPoint() {
    var value=this.value;
    var param=null;
    if(value)
    {
        param={
            center:value,
        };
    }
    var id=this.id;
    var callback=function (data) {
        $("#"+id).textbox("setValue",data.lng+","+data.lat);
    };
    openSelectWindow("/HtmlDemo/myDemo/open_window/selectMap.html","test",param,callback);
};


